<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .box1 {
      width: 400px;
      height: 400px;
      background-color: aquamarine;
    }

    .box2 {
      width: 250px;
      height: 250px;
      background-color: chartreuse;
    }

    .box3 {
      width: 100px;
      height: 100px;
      background-color: coral;
    }
  </style>
</head>

<body>
  <div id="app">
    <!-- v-on:  事件绑定  语法糖 @    绑定函数，不加括号，就是事件处理函数，函数第一个参数默认为e；加了括号不是事件处理函数，无法使用e来阻止冒泡事件-->
    <button v-on:click="alert">弹出</button>
    <div class="box1" v-on:click.self="print1">
      <!-- v-on 对冒泡的阻止  .self 绑定在自身的事件只能由自己触发-->
      <div class="box2" v-on:click="print2">
        <!-- v-on 对冒泡的阻止  .stop  与原生的stopPropagation一样 -->
        <div class="box3" v-on:click.stop="print3"></div>
      </div>
    </div>
    <div class="box1" v-on:click="print1">
      <!-- v-on 捕获阶段触发事件 .capture-->
      <div class="box2" v-on:click.capture="print2">
        <div class="box3" v-on:click="print3"></div>
      </div>
    </div>
  </div>
  <script src="../vue.js"></script>
  <script>
    const vm = new Vue({
      // el: '#app',
      methods: {
        alert() {
          confirm("你是sb吗？")
        },
        print1() {
          console.log('box1');
        },
        print2() {
          console.log('box2');
        },
        print3() {
          console.log('box3');
        }
      }
    }).$mount('#app');    //在外部将vm挂载到app上
  </script>
</body>

</html>